#
#  Players.py
#  TurnShip
#
#  Created by Pete Lord on 21/01/2009.
#  Copyright (c) 2009 __MyCompanyName__. All rights reserved.
#
#   Fun abound.

class Players(dict):
    def __setitem__(self, i, y):
        y.__setup__(self.entities, (y.number - self.entities.player.number) % (len(self) + 1))
        dict.__setitem__(self, i, y)
        
    def __setup__(self):
        for player in self.values():
            player.__setup__(self.entities, (player.number - self.entities.player.number) % len(self))
    
    def get_key(self, item):
        for key, element in self.items():
            if element == item:
                return key
        raise KeyError

class Player(object):
    def __setup__(self, entities, player):
        self.ships.__setup__(entities, player)
        
    def key(self):
        return self.__key__
